#include "widget.h"
#include "ui_widget.h"

#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    // testQThread();

    testQMutex();
}

Widget::~Widget()
{
    delete ui;
}

void Widget::testQMutex()
{
    Thread thread1;
    Thread thread2;

    thread1.start();
    thread2.start();

    thread1.wait();
    thread2.wait();

    qDebug() << Thread::num;
}

void Widget::testQThread()
{
    connect(&thread, &Thread::notify, this, &Widget::handle);

    thread.start();
}

void Widget::handle()
{
    int value = ui->lcdNumber->intValue();
    ui->lcdNumber->display(--value);
}
